package com.diandian.backend.dingding.data.controller;

import com.diandian.backend.dingding.data.param.DingdingDeptMultiTreeQueryParam;
import com.diandian.backend.dingding.data.param.DingdingDeptTreeQueryParam;
import com.diandian.backend.dingding.data.service.DingdingDeptTreeService;
import com.diandian.base.boot.starter.response.BaseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * [钉钉]部门树表
 */
@RestController
@RequestMapping("/dept/tree")
public class DingdingDeptTreeController {

    @Autowired
    private DingdingDeptTreeService dingdingDeptTreeService;

    /**
     * 查询整个组织树：单层
     * @param param
     * @return
     */
    @PostMapping("/query")
    public BaseResult query(@RequestBody DingdingDeptTreeQueryParam param) {
        param.check();
        return new BaseResult(0, "success", dingdingDeptTreeService.queryTree(param.toDTO()));
    }

    /**
     * 查询整个组织树：多层
     * @param param
     * @return
     */
    @PostMapping("/query/multi")
    public BaseResult queryMultiTree(@RequestBody DingdingDeptMultiTreeQueryParam param) {
        param.check();
        return new BaseResult(0, "success", dingdingDeptTreeService.queryMultiTree(param.toDTO()));
    }
}